package com.zmzncs.lmtc.module.finance.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zmzncs.lmtc.module.finance.dao.CapitalRecordDao;
import com.zmzncs.lmtc.module.finance.pojo.CapitalRecord;
import com.zmzncs.lmtc.module.finance.service.CapitalRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 资金记录表 服务实现类
 * </p>
 *
 * @author JD
 * @since 2020-09-07
 */
@Slf4j
@Service
public class CapitalRecordServiceImpl extends ServiceImpl<CapitalRecordDao, CapitalRecord> implements CapitalRecordService {

//    @Autowired
//    private CapitalRecordDao capitalRecordDao;
//
//    @Autowired
//    private OrderInfoDao orderInfoDao;
//
//    @Autowired
//    private CardService cardService;
//
//    @Override
//    public List<CapitalRecord> selectByManager(CapitalRecord model) {
//        return null;
//    }
//
//    @Override
//    public BigDecimal selectBalanceByManager(CapitalRecord model) {
//        return null;
//    }

//    @Override
//    public String createCapitalRecordBoLian(BoLianNoFeelOutDataForm dataForm) {
//        if(new BigDecimal(dataForm.getMoney()).compareTo(BigDecimal.ZERO) > 0 ){
//            CapitalRecord record = new CapitalRecord();
//            record.setCustomerId(Long.valueOf(dataForm.getUser_id()));
//            record.setTradeNo(dataForm.getTrade_no());
//            record.setCapitalDirection("out");
//            record.setAmount(new BigDecimal(dataForm.getMoney()));
//            record.setOrderId(dataForm.getOrder_id());
//            record.setTradeType(BolianUtil.PARK_OUT_PAY);
//            record.setTradeDescribe("车主出场缴费");
//            record.setTradeTime(DateTimeUtil.stampToTime(Long.valueOf(dataForm.getOut_time())*1000));
//            record.setCreateTime(new Date());
//            capitalRecordDao.insert(record);
//        }
//        if(new BigDecimal(dataForm.getService_fee()).compareTo(BigDecimal.ZERO) > 0 ) {
//            CapitalRecord serviceFeeRecord = new CapitalRecord();
//            serviceFeeRecord.setCustomerId(Long.valueOf(dataForm.getUser_id()));
//            serviceFeeRecord.setTradeNo(dataForm.getTrade_no());
//            serviceFeeRecord.setCapitalDirection("out");
//            serviceFeeRecord.setAmount(new BigDecimal(dataForm.getService_fee()));
//            serviceFeeRecord.setOrderId(dataForm.getOrder_id());
//            serviceFeeRecord.setTradeType(BolianUtil.SERVICE_FEE);
//            serviceFeeRecord.setTradeDescribe("三方接口服务收费");
//            serviceFeeRecord.setTradeTime(DateTimeUtil.stampToTime(Long.valueOf(dataForm.getOut_time())*1000));
//            serviceFeeRecord.setCreateTime(new Date());
//            capitalRecordDao.insert(serviceFeeRecord);
//        }
//        if(new BigDecimal(dataForm.getPoundage()).compareTo(BigDecimal.ZERO) > 0 ) {
//            CapitalRecord subsidyFeeRecord = new CapitalRecord();
//            subsidyFeeRecord.setCustomerId(Long.valueOf(dataForm.getUser_id()));
//            subsidyFeeRecord.setTradeNo(dataForm.getTrade_no());
//            subsidyFeeRecord.setCapitalDirection("in");
//            subsidyFeeRecord.setAmount(new BigDecimal(dataForm.getPoundage()));
//            subsidyFeeRecord.setOrderId(dataForm.getOrder_id());
//            subsidyFeeRecord.setTradeType(BolianUtil.SERVICE_SUBSIDY);
//            subsidyFeeRecord.setTradeDescribe("接口手续费回退补贴");
//            subsidyFeeRecord.setTradeTime(DateTimeUtil.stampToTime(Long.valueOf(dataForm.getOut_time())*1000));
//            subsidyFeeRecord.setCreateTime(new Date());
//            capitalRecordDao.insert(subsidyFeeRecord);
//        }
//
//        //  根据订单号查询订单
//        OrderInfoDTO orderInfoDTO = orderInfoDao.getByOrderCode(dataForm.getOrder_id());
//        if(orderInfoDTO!=null){
//            Long parkId = orderInfoDTO.getParkId();
//            CardHasForm cardHasForm = new CardHasForm();
//            Date carin = DateTimeUtil.stampToTime(dataForm.getIn_time() * 1000);
//            Date carOut = DateTimeUtil.stampToTime(dataForm.getOut_time() * 1000);
//            cardHasForm.setParkId(parkId);
//            cardHasForm.setCarNumber(dataForm.getPlate_number());
//            cardHasForm.setBeginTime(carin);
//            cardHasForm.setEndTime(carOut);
//            int duration = Math.toIntExact(carOut.getTime() - carin.getTime());
//            OrderInfo orderInfo = new OrderInfo();
//            orderInfo.setId(orderInfoDTO.getId());
//            orderInfo.setStatus(OrderStatusEnum.OUT.getCode());
//            orderInfo.setParkDuration(Long.valueOf(duration));
//            orderInfoDao.updateById(orderInfo);
//        }else{
//            log.info("BoLianController noFeelOutParkNotice order is null " + dataForm.getOrder_id());
//        }
//        return dataForm.getOrder_id();
//    }

}
